package cn.lijida.weiwei.favor.modules.relation.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.lijida.weiwei.favor.commons.constant.Conf;
import cn.lijida.weiwei.favor.commons.utils.ReturnT;
import cn.lijida.weiwei.favor.commons.validator.AddGroup;
import cn.lijida.weiwei.favor.modules.relation.entity.FavorRelation;
import cn.lijida.weiwei.favor.modules.relation.service.IFavorRelationService;

/**
 * <p>
 * 关系 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-12-28
 */
@RestController
@RequestMapping("/relation/center")
public class FavorRelationController {

	@Autowired
	private IFavorRelationService relationService;
	
	/**  
	 * <p>Title: create</p>  
	 * <p>Description: 创建关系</p>  
	 * @param relation
	 * @param loginId
	 * @return  
	 * @throws Exception 
	 */  
	@PostMapping("relation")
	public ReturnT<String> create(@RequestBody @Validated(AddGroup.class) FavorRelation relation,@RequestAttribute(Conf.LOGIN_ID) Long loginId) throws Exception{
		
		relationService.create(relation,loginId);
		return ReturnT.SUCCESS;
	}
}
